﻿class SessionsController < ApplicationController
  def new
  end

  def create
    if user = User.authenticate(params[:studentId], params[:password])
      session[:user_id] = user.id
        redirect_to account_url
     else
       redirect_to login_url, :alert => "#{t(:userpassvalid)}"
     end
  end

  def destroy
    session[:user_id] = nil
    redirect_to root_path, :notice => "#{t(:lo)}"
  end
end
